import { request } from "@/utils/service"
import type * as Products from "./types"

// 产品系列
/** 增 */
export function createProductsApi(data: Products.CreateOrUpdateProductsRequestData) {
  return request({
    url: "productsCategories",
    method: "post",
    data
  })
}

/** 删 */
export function deleteProductsApi(id: string) {
  return request({
    url: `productsCategories/${id}`,
    method: "delete"
  })
}

/** 改 */
export function updateProductsApi(data: Products.CreateOrUpdateProductsRequestData) {
  return request({
    url: "productsCategories/" + data.id,
    method: "put",
    data
  })
}

/** 查 */
export function getProductsApi(params: Products.GetProductsRequestData) {
  return request<Products.GetProductsResponseData>({
    url: "productsCategories",
    method: "get",
    params
  })
}

/** 查详情 */
export function getProductsDetailApi(id: string) {
  return request<Products.GetProductsResponeseDetailData>({
    url: `productsCategories/${id}`,
    method: "get"
  })
}
// 产品

/** 增 */
export function createProductsChildrenApi(data: Products.CreateOrUpdateProductsChildrenRequestData) {
  return request({
    url: "products",
    method: "post",
    data
  })
}

/** 删 */
export function deleteProductsChildrenApi(id: string) {
  return request({
    url: `products/${id}`,
    method: "delete"
  })
}

/** 改 */
export function updateProductsChildrenApi(data: Products.CreateOrUpdateProductsChildrenRequestData) {
  return request({
    url: "products/" + data.id,
    method: "put",
    data
  })
}

/** 查 */
export function getProductsChildrenApi(params: Products.GetProductsChildrenRequestData) {
  return request<Products.GetProductsChildrenResponeseData>({
    url: "products",
    method: "get",
    params
  })
}

/** 查详情 */
export function getProductsChildrenDetailApi(id: string) {
  return request<Products.GetProductsChildrenResponeseDetailData>({
    url: `products/${id}`,
    method: "get"
  })
}
